<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>云校通-教师-学生积分查询</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
<body ontouchstart>
	<div class="weui_tab tab-bottom">
        <div class="weui_tab_bd">
        	<div class="weui-header bg-blue"> 
		  		<div class="weui-header-left"> <a href="javascript:;" onclick="back()" class="icon icon-109 f-white">返回</a> </div>
		    	<h1 class="weui-header-title">学生积分查询</h1>
		    </div>
            <div class="weui_tab kcfd-list1" id="tab3" style="transform-origin: 0px 0px 0px; opacity: 1; transform: scale(1, 1);">
	            <div class="weui_navbar">
	                <div class="weui_navbar_item tab-blue">总览</div>
                    <div class="weui_navbar_item">加分</div>
                    <div class="weui_navbar_item">减分</div>
	            </div>
	            <div class="weui_tab_bd">
		            <div class="weui_panel weui_tab_bd_item qingjia mt0">
		            	<div class="point">
		                      <ul>
		                        <li>
		                          <strong class="f-orange totalPoint">0</strong>
		                          <p>总分</p>
		                        </li>
		                        <li>
		                          <strong class="f-red termPoint">0</strong>
		                          <p>本学期</p>
		                        </li>
		                        <li class="last_l">
		                          <strong class="f-red monthPoint">0</strong>
		                          <p>本月度</p>
		                        </li>
		                      </ul>
	                    </div>
	                    <p class="f20 p10">积分详情</p>
		            	<div class="weui_panel_bd">
	                    	<div class="weui_media_box weui_media_small_appmsg">
			                    <div class="weui_cells weui_cells_access" id="totalList">
			                   </div>
			                 </div>  
			            </div>
						<div class="dropload-down">
				        	<div class="loadData dropload-hasData">点击加载更多数据...</div>
				        </div>
			        </div>
		            <div class="weui_panel weui_tab_bd_item qingjia mt0">
		            	<div class="point">
		                      <ul>
		                        <li>
		                          <strong class="f-orange totalPoint">0</strong>
		                          <p>总分</p>
		                        </li>
		                        <li>
		                          <strong class="f-red termPoint">0</strong>
		                          <p>本学期</p>
		                        </li>
		                        <li class="last_l">
		                          <strong class="f-red monthPoint">0</strong>
		                          <p>本月度</p>
		                        </li>
		                      </ul>
	                    </div>
	                    <p class="f20 p10">积分详情</p>
		            	<div class="weui_panel_bd">
	                    	<div class="weui_media_box weui_media_small_appmsg">
			                    <div class="weui_cells weui_cells_access" id="jiaList">
			                   </div>
			                 </div>  
			            </div>
						<div class="dropload-down">
				        	<div class="loadData dropload-hasData">点击加载更多数据...</div>
				        </div>
			        </div>
			        <div class="weui_panel weui_tab_bd_item qingjia mt0">
				        	<div class="point">
		                      <ul>
		                        <li>
		                          <strong class="f-orange totalPoint">0</strong>
		                          <p>总分</p>
		                        </li>
		                        <li>
		                          <strong class="f-red termPoint">0</strong>
		                          <p>本学期</p>
		                        </li>
		                        <li class="last_l">
		                          <strong class="f-red monthPoint">0</strong>
		                          <p>本月度</p>
		                        </li>
		                      </ul>
	                    </div>
	                    <p class="f20 p10">积分详情</p>
		            	<div class="weui_panel_bd">
	                    	<div class="weui_media_box weui_media_small_appmsg">
			                    <div class="weui_cells weui_cells_access" id="jianList">
			                   </div>
			                 </div>  
			            </div>
						<div class="dropload-down">
				        	<div class="loadData dropload-hasData">点击加载更多数据...</div>
				        </div>
			        </div>
	            </div>
	        </div>
	      </div> 
      </div>
</body>
<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
<script>
   var totalPage = 0, jiaPage = 0, jianPage = 0;
   var totalRows = 10, jiaRows = 10, jianRows = 10;
   var keyId = "${user.parent.studentId}";
   $(function(){
	    $('#tab3').tab({
			defaultIndex: 0,
			activeClass: "tab-blue "
		});
	    $("#tab3 .weui_navbar_item").click(function() {
	    	var index = $(this).index();
	    	if(index == 0) totalRoutine();
	    	else if(index == 1) jiaRoutine();
	    	else if(index == 2) jianRoutine();
	    })
	    $(".dropload-down").on("click", ".dropload-hasData", function() {
	    	var index = $(this).closest(".weui_tab_bd_item").index();
	    	if(index == 0) totalRoutine();
	    	else if(index == 1) jiaRoutine();
	    	else if(index == 2) jianRoutine();
	    });
	    loadTotalPoints();
        totalRoutine();
   });
   function loadTotalPoints() {
	   $.ajax({
			url : basePath + "/ls/student/points/totalPoint",
			type : "post",
			dataType : "json",
			data : {
				keyId: keyId
			},
			async : false,
			success : function(data) {
				if(data != null) {
					$(".totalPoint").html((data.totalPoint > 0 ? "+" : "-") + data.totalPoint);
					$(".termPoint").html((data.termPoint > 0 ? "+" : "-") + data.termPoint);
					$(".monthPoint").html((data.monthPoint > 0 ? "+" : "-") + data.monthPoint);
				}
			}, error:function(){
			}
		});
   }
   function totalRoutine() {
	   totalPage = totalPage + 1;
	   var params = {
			page: totalPage,
			rows: totalRows,
			keyId: keyId
	   }
	   loadRoutineList(params,"totalList");
   }
   function jiaRoutine() {
	   jiaPage = jiaPage + 1;
	   var params = {
			page: jiaPage,
			rows: jiaRows,
			keyId: keyId,
			scoreCompare: 1
	   }
	   loadRoutineList(params,"jiaList");
   }
   function jianRoutine() {
	   jianPage = jianPage + 1;
	   var params = {
			page: jianPage,
			rows: jianRows,
			keyId: keyId,
			scoreCompare: -1
	   }
	   loadRoutineList(params,"jianList");
   }
   function loadRoutineList(params, id) {
	   $.ajax({
			url : basePath + "/ls/student/points/routine/pageQuery",
			type : "post",
			data : params,
			dataType : "json",
			async : false,
			success : function(data) {
				if(data != null) {
					if(data.rows.length == 0 || params.page*params.rows >= data.total) {// 如果没有数据
	            		 $("#" + id).closest(".weui_tab_bd_item").find('.loadData').removeClass("dropload-hasData").addClass("dropload-noData").html("没有更多数据了");
	                 	 if(data.rows.length == 0) return;
	                }
					var html = "";
					for(var i in data.rows) {
						var itm = data.rows[i];
						html += '<a class="weui_cell" href="<%=basePath %>/xs/student/points/routine/detail/'+itm.id+'?sid=${user.parent.studentId}">\
							<div class="weui_cell_bd weui_cell_primary">\
							<h4 class="weui_media_title">'+itm.judgeType+'</h4>\
	                        <span class="point_score">'+(itm.score > 0 ? "+" : "")+itm.score+'</span>\
	                        <p class="weui_media_desc pt10">'+itm.judgeContent+'</p>\
	                        <p class="weui_media_desc">'+getTime(itm.judgeTime, "yyyy-MM-dd hh:mm")+'</p></div>\
						<span class="weui_cell_ft"></span></a>';
					}
					$("#" + id).append(html);
				}
			}, error:function(){
			}
		});
   	}
</script>
</html>